package menu;

import java.util.*;
import java.util.Iterator;

/**
 * @author: Alexander Martyushov
 */
public class Menu extends MenuComponent {

    ArrayList menuComponent = new ArrayList();
    String name;
    String description;

    public Menu(String name, String description){
        this.name=name;
        this.description=description;
    }

    public void add(MenuComponent menuComponent){
        menuComponent.add(menuComponent);
    }

    public void remove(MenuComponent menuComponent){
        menuComponent.remove(menuComponent);
    }

    public String getName() {
        return name;
    }

    public String getDescription() {
        return description;
    }

    public void print(){
        System.out.println( "\n" + getName());
        System.out.println( ", " + getDescription());
        System.out.println( "-------------------");

        Iterator iterator = menuComponent.iterator();
        while (iterator.hasNext()){
            MenuComponent menuComponent = (MenuComponent) iterator.next();
            menuComponent.print();
        }
    }
}
